/*
 * @Description: 
 * @Author: wangqi
 * @Date: 2021-04-20 07:13:01
 * @LastEditTime: 2021-04-24 19:11:31
 */
const loaderUtils = require('loader-utils')

let style = ``;
//  style.innerHTML = JSON.stringify(loader) 可以将index.less的代码转为一行
function loader(source) {
    style = `let style = document.createElement('style'); style.innerHTML = ${JSON.stringify(source)}; document.head.appendChild(style)`;
    return style;
};

loader.pitch = function(remainingRequest){
    let str = `
        let style = document.createElement('style'); 
        style.innerHTML = require(${loaderUtils.stringifyRequest(this, '!!' + remainingRequest)}); 
        document.head.appendChild(style);
    `;

    return str
}

module.exports = loader

